import Vue from 'vue'
import VueRouter from 'vue-router'
// import login from '@/views/login'
Vue.use(VueRouter)

const routes = [
    // {
    //   path:'/',
    //   redirect:'/login'
    // },
    { 
    path: '/login',
    // component: login,//这样写会导致在一开始的时候就会把所有的js文件下载
    //路由懒加载
    component:() => import('@/views/login')
    },
    {
      path:'/',
      component: ()=> import('@/views/layout'),
      redirect: '/home',
      children:[
        { 
          path: 'home', 
          component: ()=> import('@/views/home') 
        },
        { 
          path: 'qa',
          component: ()=> import('@/views/qa') 
        },
        { 
          path: 'my', 
          component: ()=> import('@/views/my') 
        },
      ]
    },
    { 
      path: '/article/:id', 
      component: ()=> import('@/views/article'),
      props: true
    }
]

const router = new VueRouter({
  routes
})

export default router
